package event

import "time"

type DataType = any

type DomainEvent interface {
	GetId() string
	GetSource() string
	GetData() DataType
	GetTimeStamp() int64
}

type BaseDomainEvent struct {
	id        string
	source    string
	data      DataType
	timestamp int64
}

func NewEvent(id string, source string, data DataType) DomainEvent {
	return &BaseDomainEvent{
		id:        id,
		source:    source,
		data:      data,
		timestamp: time.Now().UnixNano(),
	}
}

func (b *BaseDomainEvent) GetId() string {
	return b.id
}

func (b *BaseDomainEvent) GetSource() string {
	return b.source
}

func (b *BaseDomainEvent) GetData() DataType {
	return b.data
}

func (b *BaseDomainEvent) GetTimeStamp() int64 {
	return b.timestamp
}
